﻿namespace SBlogCore.WebAdminApplication.SysManager.CacheServices
{
    public  interface IMenuCacheService
    {
        /// <summary>
        /// 获取菜单缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<T?> GetMenu<T>(string key);
        /// <summary>
        /// 获取或者创建菜单缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="valueFactory"></param>
        /// <returns></returns>
        Task<T?> GetOrCreateMenu<T>(string key, Func<Task<T>>? valueFactory = null);
        /// <summary>
        /// 存储菜单缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        Task SetMenu<T>(string key, T data);
        /// <summary>
        /// 删除指定key
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>

        Task DeleteMenu(string key);

        /// <summary>
        /// 清楚所有的缓存
        /// </summary>
        /// <returns></returns>
        Task ClearMenu();
    }
}
